package com.demo77_组合;

import java.util.ArrayList;
import java.util.Stack;

public class StackText {
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        // 1. 往栈里面添加元素,压栈
        stack.push(1);
        stack.push(2);
        stack.push(2);
        stack.push(4);
        stack.push(5);
        stack.push(6);

        //2. 弹出栈顶元素
        Integer pop = stack.pop();
        System.out.println("栈顶元素是:"+pop);
        System.out.println("此时栈的大小是:"+stack.size());
        System.out.println("=================================");
        //3. 查看栈顶元素
        Integer peek = stack.peek();
        System.out.println("栈顶元素是:"+peek);
        System.out.println("此时栈的大小是:"+stack.size());
        System.out.println("=================================");

        //4. 判断栈中是否为空
        boolean empty = stack.isEmpty();
        System.out.println(empty);

        //5. 判断是否为空
        boolean empty1 = stack.empty();
        System.out.println(empty1);

        //6. 把集合里面的元素添加到栈中
        ArrayList<Integer> list = new ArrayList<>();
        list.add(100);
        stack.addAll(list);


    }
}
